package com.framework.web.bus.service;

import com.framework.web.bus.domain.Express;
import com.framework.web.bus.repository.ExpressRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author fusf
 * @version V1.0
 * @Title: Service
 * @Description: 业务层
 * @date 2016-11-21
 */
@Service
public class ExpressService {

    @Autowired
    private ExpressRepository expressRepository;

    /**
     * 新增或者保存
     *
     * @param express
     * @return
     */
    public Express save(Express express) {
        return expressRepository.save(express);
    }

    /**
     * 删除
     *
     * @param id
     */
    public void delete(String id) {
        expressRepository.delete(id);
    }

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    public Express findById(String id) {
        return expressRepository.findOne(id);
    }


    /**
     *
     * 查询list
     * @param orderId
     * @return
     */
    public List<Express> findAllByOrderId(String orderId) {
        List<Express> totalList = expressRepository.findByOrderIdOrderByTime(orderId);
        return totalList;
    }

}
